/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Kevin
 */

import java.util.Date; 
import java.util.Properties; 

import javax.mail.Message; 
import javax.mail.Session; 
import javax.mail.Transport; 
import javax.mail.internet.InternetAddress; 
import javax.mail.internet.MimeMessage; 

public class SendMail { 

public static void send(String str_to,String str_content) { 


try { 

Properties props=new Properties(); 

props.put("mail.smtp.host","smtp.gmail.com"); 

props.put("mail.smtp.auth","true"); 
props.put("mail.smtp.starttls.enable","true");

Session s=Session.getInstance(props); 
s.setDebug(true); 

MimeMessage message=new MimeMessage(s); 


InternetAddress from= new InternetAddress("fakeeventcinema@gmail.com");
message.setFrom(from); 


InternetAddress to=new InternetAddress(str_to);
message.setRecipient(Message.RecipientType.TO, to); 


message.setSubject("Register comfirm mail from EventCinema!"); 

message.setContent(str_content, "text/html;charset=utf-8"); 

message.setSentDate(new Date()); 


message.saveChanges(); 


Transport transport=s.getTransport("smtp"); 

transport.connect("smtp.gmail.com","fakeeventcinema@gmail.com","fake_event_cinema"); 

transport.sendMessage(message,message.getAllRecipients()); 
transport.close(); 

} catch (Exception e) { 
e.printStackTrace(); 
} 
} 
    public static void main(String[] args) { 
        
send("lowkeymelody@gmail.com","<b>hello</b>"); 
} 
}

